from groups.models import *
from django.shortcuts import render_to_response, get_object_or_404 
from django.template import RequestContext
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, Http404
from django.views.decorators.csrf import csrf_exempt, csrf_protect
from django.contrib.auth.decorators import login_required
from groups.forms import GroupForm

@csrf_exempt
def create_group(request):
    groupform = GroupForm(request.POST or None)
    next = 'no'
    if groupform.is_valid():
        group = groupform.save( commit = False )
        group.owner =  request.user
        group.save()
        next = 'yes'
    return render_to_response ( 
        'groups/group_create.html',
        {
         'groupform' :  groupform,
         'next': next,
        },
        context_instance = RequestContext(request)
        )
